package com.itheima.day14.threadpool.test3;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

// ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(核心线程数量,最大线程数量,空闲线程最大存活时间,任务队列,创建线程工厂,任务的拒绝策略);
public class Test {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2,4,2, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10), Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());
        //                                                            (核心线程数量,      最大线程数量,         空闲线程最大存活时间,             任务队列,                               创建线程工厂,                                           任务的拒绝策略);

        System.out.println(threadPoolExecutor.getPoolSize()); // 0

        threadPoolExecutor.submit(new MyRubbable());
        threadPoolExecutor.submit(new MyRubbable());
        threadPoolExecutor.submit(new MyRubbable());

        System.out.println(threadPoolExecutor.getPoolSize()); // 2

        threadPoolExecutor.shutdown();
    }
}
